'''
添加成员页面
'''
import time

from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.by import By

from page_object.base_page import BasePage
from page_object.contact_page import ContactPage


class AddMemberPage(BasePage):
    # 如果一个参数是一个元组时，则需要兼容，用解包的方式
    # 变量前面加入下划线，表示私有参数,仅限此类使用
    _username = (By.ID, "username")
    _memberAdd_acctid = (By.ID, "memberAdd_acctid")

    def goto_contact(self):
        return ContactPage(self.driver)

    def add_member(self, mem_name, mem_id, mem_phone):
        '''
        添加成员操作
        :return:
        '''
        self.driver.implicitly_wait(3)
        self.find(self._username).send_keys(mem_name)
        self.driver.find_element(self._memberAdd_acctid).send_keys(mem_id)
        self.driver.find_element(By.ID, 'memberAdd_phone').send_keys(mem_phone)
        self.driver.find_element(By.CSS_SELECTOR, '.js_btn_save').click()
        return ContactPage(self.driver)
